from django.template import loader, RequestContext
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from django import newforms as forms
from duetopia.register.models import Agent, Organization, Location, DataSet
from duetopia.register.views.generic import edit_object

__all__ = ['view_agent']

def view_agent(request, pk, template='register/view_agent.html'):
    agent = get_object_or_404(Agent, pk=pk)
    datasets = DataSet.objects.filter(contacts=agent)
    context = {
        'agent' : agent,
        'datasets': datasets,
        'tilecache': settings.TILECACHE,
        'baseurl' : settings.WWW_BASEURL,
    }
    c = RequestContext(request, context)
    t = loader.get_template(template)
    return HttpResponse(t.render(c))

    
